<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>
<%@ page import="com.google.appengine.api.datastore.DatastoreServiceFactory" %>
<%@ page import="com.google.appengine.api.datastore.DatastoreService" %>
<%@ page import="com.google.appengine.api.datastore.Query" %>
<%@ page import="com.google.appengine.api.datastore.Entity" %>
<%@ page import="com.google.appengine.api.datastore.FetchOptions" %>
<%@ page import="com.google.appengine.api.datastore.Key" %>
<%@ page import="com.google.appengine.api.datastore.KeyFactory" %>

<html>
<head>
<title>TweetGraph</title>
<script type='text/javascript' src="scripts/jquery-1.7.1.min.js"></script>
<script type='text/javascript' src="scripts/core.js"></script>
<link href="styles/tweetgraph.css" type="text/css" rel="stylesheet" />
<link href="styles/bootstrap.css" type="text/css" rel="stylesheet" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,700' rel='stylesheet' type='text/css'>
</head>
<script type="text/javascript">
<!--
	function submitQuery(qType){
		document.qForm.action="/queryprocessor";
		document.qForm.mode.value=qType;
		document.qForm.submit();
	}
//-->
</script>
<%

	Query query = new Query("QueryResult");
	DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
	List<Entity> results = datastore.prepare(query).asList(FetchOptions.Builder.withLimit(10));

%>
<body>
<form method="post" name="qForm" action="">
	<input type="hidden" name="mode" value=""/>


<div id="main">
	<div id="header">
		<a href="index.html"><img src="images/logo.png" class="logo"></a>
		<ul id="top_nav">
			<li><a href="index.html">Home</a></li>
			<li><a href="signup.html">Sign Up</a></li>
			<li><a href="#">Contact</a></li>
		</ul>
	</div>
	<div id="content">
		<h3>Saved Results</h3>
		<div id="select_left" class="container">
			<%
				if(results.size() > 0){
						String tag="";
						String name ="";
						for(Entity ent:results){
							tag = (String)ent.getProperty("tag");
							name = (String)ent.getProperty("name");
							
							%>
							
							<div id="example1" class="example">
							<a href="graph.jsp?hashTag=<%=tag%>&name=<%=name%>"><img src="images/btn_pie_small.png"></a>
							<p>Name: <b><%=name %></b><br> 
							Search Term: <b>#<%=tag%></b></p></div>
							<br><br>
						<%}
				}else{%>
					No results found.	
				<%}
			%>
		
		</div>
	</div>
	<div class="clear"></div>
	<div id="footer">
		<ul id="bottom_nav">
			<li>Copyright &copy; 2012</li>
		</ul>
	</div>

</div>
</form>
</body>

</html>